This page last changed on Aug 13, 2007 by cholmes.

Overview

Though not a specific Google Earth feature, GeoServer has a powerful capability to limit the data returned based on a query passed in by the user. The KML Reflector will pass through any 'FILTER' or 'CQL_FILTER" parameter to GeoServer to constrain the response. Filters are basically a translation of a SQL 'WHERE' statement in to web form, and allow the full power of SQL, though limited to a single table. One can do logical filters, like AND and OR, to make very complex queries, leveraging numerical and string comparisons, geometric operations (bbox, touches, intersects, disjoint), LIKE statements, nulls, and more.

OGC Filters

There is an open standard put out by the Open Geospatial COnsortium called 'Filter Encoding' GeoServer implements the full spec, so read it for the full language with examples.

There simplest filter is very easy to include. It is called the 'featureid' filter, and it lets you grab a single feature by saying its id:

This request will take you to the state of Maryland. The featureids of your data are most easily found by doing WFS requests and examining the resulting GML. KML output will also include the featureids if there is not a template that overrides it.

After the basics using Filters in a URL gets a little out of hand, as one is supposed to include a full XML filter inside the url, like:

http:/localhost:8080/geoserver/wms/kml_reflect?layers=topp:states&FILTER=%3CFilter%3E%3CPropertyIsBetween%3E%3C
PropertyName%3Etopp:LAND_KM%3C/PropertyName%3E%3CLowerBoundary%3E%3CLiteral%3E100000%3C/Literal%3E%3C/LowerBoundary
%3E%3CUpperBoundary%3E%3CLiteral%3E150000%3C/Literal%3E%3C/UpperBoundary%3E%3C/PropertyIsBetween%3E%3C/Filter%3E

So we don't recommend using those. Instead there is CQL, which allows one to specify the same long statement much more succinctly.

CQL Filters

See Common Query Language (CQL) Tutorial (unfinished) for an introduction to CQL queries.

For right here we'll just demonstrate what the above query would be in CQL:

Which is much more compact. That query will get you all the states in the US with square kilometers of land between 100,000 and 150,000:


ge-pop.tiff (image/tiff)
Document generated by Confluence on Jan 16, 2008 23:28